/*
 * 2.  Nhập/ xuất số nguyên ra/vào file text 
 */
package Bai2;

import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class HomeWork {
	private List<Integer> list;
	
	//constructor
	public HomeWork() {
		list = new ArrayList<Integer>();
	}
	
	//gettor
	
	//settor
	
	//ham nhap list so nguyen
	public void enterDataL() {
		Scanner scanner = new Scanner(System.in);
		int n;
		for(int i = 0; i < 5; i++) {
			System.out.print("N " + i + ": ");
			n = scanner.nextInt();
			list.add(n);
		}
	}
	
	//ham ghi list ra file
	public void writeDataToFile() {
		FileOutputStream fOut;
		
		try {
			fOut = new FileOutputStream("bai2.integer.txt");
			PrintWriter pW = new PrintWriter(fOut, true);
			
			for(int i = 0; i < list.size(); i++) {
				System.out.print(list.get(i) + "\t");
				pW.println(list.get(i));
			}
			
			fOut.close();
			pW.close();
			
		}
		catch (Exception e) {
			System.out.print("Couldn't write to file!");
		}
	}
}
